/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spakehelpdesk.session;

import com.spakehelpdesk.entity.Role;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author leehoanh
 */
@Stateless
@LocalBean
public class RoleSession {
    @PersistenceContext(unitName = "Spake_Helpdesk-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    //select all role in system
     public List<Role> getAll()
    {
        Query query = em.createNamedQuery("Role.findAll");
        try {
            return query.getResultList();
        } catch (Exception e) {
            return null;
        }
        
    }
    
}
